-
-
Notifications
You must be signed in to change notification settings - Fork 2
Support SystemD LISTEN_FDS. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Receive pre-bound UDP and TCP sockets via the LISTEN_FDS environment variable.
|
Damn, my editor has reformatted more than just the changes I made. I'll resubmit that without the extra changes. |
Fixed. |
src/process.rs
Outdated
| /// as it calls [`std::env::remove_var()`]. | ||
| pub fn from_env(unset_environment: bool) -> Self { | ||
| let own_pid = nix::unistd::Pid::this().as_raw().to_string(); | ||
| let var_pid = std::env::var("LISTEN_PID").unwrap_or_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think env::var_os will be enough here, sparing us one check (not that it matters much).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you would lose the knowledge that the var was not set, which if you expect it to be set could be important to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you unwrap_or_default anyway? Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code has since changed. It not captures the unset env var case as EnvSocketsError::NotAvailable.
- Return errors instead of logging warnings. - Factor out env var removal to a separate method. - Take the number of FDs to expect, don't hard-code an upper bound.
…ent unsafe behaviour.
…a Linux thing, and update code accordingly.
Thereby allowing callers to use the EnvSockets instance even if init_from_env() fails.
New * Reworked setting of user and group. If not provided explicitly, the group will now be set to the user’s group. The list of supplemental groups will be initialized from the user’s group list. ([#11]) * Allow manually creating the process configuration so it can be used without the _clap_ argument parser. ([#12]) * Added support for systemd’s socket activation. ([#13])
Receive pre-bound UDP and TCP sockets via the LISTEN_FDS environment variable.
See NLnetLabs/cascade#53 for this branch in use.